#include <iostream>
#include<stdlib.h>
using namespace std;
#define maxsize 100001
typedef struct{
	int data[maxsize];
	int length;
}SqList;
typedef SqList *List;
void CreateSqList(List &L,int a[],int n);
void DestroyList(List &L);
int result(List &ha,List &hb);
void DestroyList(List &L){
	delete L;
}
int main()
{
	int i,n,number;
	int a[maxsize],b[maxsize];
	List ha,hb;
	cin>>n; 
	for(i=0;i<n;i++)
	   cin>>a[i];
	 CreateSqList(ha,a,n);
	 for(i=0;i<n;i++)
	   cin>>b[i];
	 CreateSqList(hb,b,n);
	 number=result(ha,hb);
	 cout<<number;
	 DestroyList(ha);
	 DestroyList(hb);
	 return 0;
}
void CreateSqList(List &L,int a[],int n){
	int i;
	L=(SqList*)malloc(sizeof(SqList));
    L->length=n;
  for(i=0;i<n;i++){
  	L->data[i]=a[i]; 
  }
}
int result(List &ha,List &hb){
	int i=0,j=0,k=0;
	while(i<ha->length&&j<hb->length){
		k++;
		if(ha->data[i]<hb->data[j]){
			if(k==ha->length)
			return ha->data[i];
			i++;
		}
		else{
		if(k==hb->length)
		return hb->data[j];
		j++;
		}
	}
}



